<script type="text/javascript">
    try {
        var openarr = $openarr;
    } catch (e) {
    }
    $.getScript('dzz/system/scripts/selorg.js?{VERHASH}', function () {
        selorg.openarr = openarr;
    });
</script>
<style type="text/css">
	.org-sel-box.dropdown-menu {
		padding: 0px;
	}
</style>
<div class="card-body scroll-y">
    <form class="form-horizontal" action="{MOD_URL}&op=app&do=updatesetting" onsubmit="return submitsetting(this);">
		<div class="row mb-1">
			<label class="col-sm-2" for="usermemory">{lang start_person_dir}</label>
			<div class="col-sm-10">
				<div class="form-check form-switch">
					<input type="checkbox" class="form-check-input" id="usermemory" name="setting[explorer_usermemoryOn]" <!--{if $setting['explorer_usermemoryOn']==1 || !isset($setting['explorer_organizationOn'])}-->checked<!--{/if}--> />
				</div>
			</div>
		</div>
		<div class="row mb-3">
			<label class="col-sm-2"></label>
			<div class="col-sm-10">
				<div id="memoryinfo" <!--{if isset($setting['explorer_organizationOn']) && $setting['explorer_usermemoryOn'] == 0}-->class="hide"<!--{/if}--> >
					<div class="function-radio clearfix">
						<div class="form-check form-check-inline">
							<input type="radio" class="form-check-input" value="all" id="allsetting" name="setting[explorer_mermoryusersetting]" <!--{if !isset($setting['explorer_mermoryusersetting']) || $setting['explorer_mermoryusersetting'] == 'all'}-->checked<!--{/if}--> >
							<label class="form-check-label" for="allsetting">{lang all_personnel}</label>
						</div>
						<span class="form-text">{lang organizational_structure_generate_personal_storage}</span>
					</div>
					<div class="function-radio clearfix">
						<div class="form-check form-check-inline">
							<input type="radio" id="inputRadiosUnchecked" class="form-check-input" name="setting[explorer_mermoryusersetting]" value="appoint"
							<!--{if $setting['explorer_mermoryusersetting']=='appoint'}-->checked
							<!--{/if}--> >
							<label class="form-check-label" for="inputRadiosUnchecked">{lang designated_personnel_or_department_personnel}</label>
						</div>
					</div>
					<span class="form-text">{lang storage_designated_personnel_or_department_personnel}</span>
				</div>
				<div class="selectorguser" <!--{if $setting['explorer_mermoryusersetting']!='appoint'}-->style="display:none"<!--{/if}-->>
					<div class="clearfix">
						<div class="d-flex" id="orgids">
							<!--{loop $sel_org $value}-->
							<button id="orgids_sl_$value['orgid']" type="button" class="btn btn-outline-primary btn-sorg" data-val="$value['orgid']">
								{eval echo avatar_group($value['orgid'],null,'iconFirstWord');}
								$value[orgname] <a href="javascript:;" class="mdi mdi-close" title="{lang delete}" onclick="selorg.remove('orgids',this);"></a>
							</button>
							<!--{/loop}-->
							<!--{loop $sel_user $value1}-->
							<button id="orgids_sl_uid_$value1['uid']" data-val="uid_$value1['uid']" type="button" class="btn btn-outline-primary btn-sorg">
								{eval echo avatar_block($value1['uid'],array($value1['uid']=>$value1['headerColor']),'iconFirstWord');} $value1['username'] <a href="javascript:;" class="mdi mdi-close" title="{lang delete}" onclick="selorg.remove('orgids',this);"></a>
							</button>
							<!--{/loop}-->
						</div>
						<input id="sel_orgids" name="setting[explorer_memoryorgusers]" type="hidden" value="$setting['explorer_memoryorgusers']"/>
					</div>
					<div class="dropdown">
						<a href="javascript:;" class="dropdown-toggle btn btn-primary" id="orgids_Menu" data-toggle="dropdown">{lang select_departments_or_users}<span class="caret"></span></a>
						<div id="orgids_dropdown_menu" class="dropdown-menu org-sel-box" role="menu" aria-labelledby="orgids_Menu">
							<iframe name="orgids_iframe" class="org-sel-box-iframe" src="{DZZSCRIPT}?mod=system&op=orgtree&template=1&ctrlid=orgids&multiple=1&range=1" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" allowtransparency="true"></iframe>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="row mb-3">
			<label class="col-sm-2" for="explorer_organizationOn">{lang allow_use_org}</label>
			<div class="col-sm-10">
				<div class="form-check form-switch">
					<input type="checkbox" class="form-check-input" name="setting[explorer_organizationOn]" <!--{if (isset($setting['explorer_organizationOn']) && $setting['explorer_organizationOn']) || !isset($setting['explorer_organizationOn'])}-->checked<!--{/if}--> id="explorer_organizationOn" />
				  </div>
			</div>
		</div>
		<div class="row mb-3">
			<label class="col-sm-2" for="explorer_groupOn">{lang allow_use_group}</label>
			<div class="col-sm-10">
				<div class="form-check form-switch">
					<input type="checkbox" class="form-check-input" name="setting[explorer_groupOn]" <!--{if (isset($setting['explorer_groupOn']) && $setting['explorer_groupOn']) || !isset($setting['explorer_groupOn'])}-->checked <!--{/if}--> id="explorer_groupOn" />
				  </div>
			</div>
		</div>
		<div class="row mb-1">
			<label class="col-sm-2" for="usercreatememory">{lang allow_create_group}</label>
			<div class="col-sm-10">
				<div class="form-check form-switch">
					<input type="checkbox" class="form-check-input" name="setting[explorer_groupcreate]" id="usercreatememory" <!--{if (isset($setting['explorer_groupcreate']) && $setting['explorer_groupcreate']) || !isset($setting['explorer_groupcreate'])}-->checked <!--{/if}--> />
				  </div>
			</div>
		</div>
		<div class="row mb-3">
			<label class="col-sm-2"></label>
			<div class="col-sm-10">
				<div  id="memorycreateinfo" <!--{if isset($setting['explorer_groupcreate']) && $setting['explorer_groupcreate'] == 0}-->class="hide"<!--{/if}--> >
					<div class="function-radio clearfix">
						<div class="form-check form-check-inline">
							<input type="radio" class="form-check-input" id="explorer_mermorygroupsetting1" value="all" name="setting[explorer_mermorygroupsetting]"<!--{if !isset($setting['explorer_mermorygroupsetting']) || $setting['explorer_mermorygroupsetting'] == 'all'}-->checked<!--{/if}--> >
							<label class="form-check-label" for="explorer_mermorygroupsetting1">{lang all_personnel}</label>
						</div>
						<span class="form-text">{lang allow_allcreate_group}。</span>
					</div>
					<div class="function-radio clearfix">
						<div class="form-check form-check-inline">
							<input type="radio" class="form-check-input" id="explorer_mermorygroupsetting2" name="setting[explorer_mermorygroupsetting]" value="appoint"<!--{if $setting['explorer_mermorygroupsetting']=='appoint'}-->checked<!--{/if}--> >
							<label class="form-check-label" for="explorer_mermorygroupsetting2">{lang designated_personnel_or_department_personnel}</label>
						</div>
						<span class="form-text">{lang allow_appointcreate_group}</span>
					</div>
				</div>
				<div class="selectgroupuser"<!--{if $setting['explorer_mermorygroupsetting']!='appoint'}-->style="display:none;"<!--{/if}-->>
					<div class="clearfix">
						<div id="groupcreateids">
							<!--{loop $sel_org1 $value}-->
							<button id="groupcreateids_sl_$value['orgid']" type="button" class="btn btn-outline-primary btn-sorg" data-val="$value['orgid']">
								{eval echo avatar_group($value['orgid'],null,'iconFirstWord');}
								$value[orgname] <a href="javascript:;" class="mdi mdi-close" title="{lang delete}" onclick="selorg.remove('groupcreateids',this);"></a>
							</button>
							<!--{/loop}-->
							<!--{loop $sel_user1 $value1}-->
							<button id="groupcreateids_sl_uid_$value1['uid']" data-val="uid_$value1['uid']" type="button" class="btn btn-outline-primary btn-sorg">
								{eval echo avatar_block($value1['uid'],array($value1['uid']=>$value1['headerColor']),'iconFirstWord');}$value1['username'] <a href="javascript:;" class="mdi mdi-close"  title="{lang delete}" onclick="selorg.remove('groupcreateids',this);"></a>
							</button>
							<!--{/loop}-->
						</div>
						<input id="sel_groupcreateids" name="setting[explorer_memorygroupusers]" type="hidden" value="$setting['explorer_memorygroupusers']"/>
					</div>
					<div class="dropdown">
						<a href="javascript:;" class="dropdown-toggle btn btn-primary" id="groupcreateids_Menu" data-toggle="dropdown">{lang select_departments_or_users}
							<span class="caret"></span></a>
						<div  class="dropdown-menu org-sel-box" role="menu" aria-labelledby="groupcreateids_Menu">
							<iframe name="groupcreateids_iframe" class="org-sel-box-iframe"
									src="{DZZSCRIPT}?mod=system&op=orgtree&ctrlid=groupcreateids&template=1&multiple=1&range=1"
									frameborder="0" marginheight="0" marginwidth="0" width="100%"
									height="100%" allowtransparency="true"></iframe>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="row mb-3">
			<label class="col-sm-2">群组成员选择</label>
			<div class="col-sm-10">
				<div class="form-check form-check-inline">
					<input type="radio" class="form-check-input" id="explorer_mermoryonlymyorg1" value="1" name="setting[explorer_mermoryonlymyorg]"<!--{if $setting['explorer_mermoryonlymyorg'] == '1'}-->checked<!--{/if}--> >
					<label class="form-check-label" for="explorer_mermoryonlymyorg1">所有机构部门</label>
				</div>
				<span class="form-text">可以选择全站所有成员</span>
				<div class="form-check form-check-inline">
					<input type="radio" class="form-check-input" id="explorer_mermoryonlymyorg2" value="0" name="setting[explorer_mermoryonlymyorg]"<!--{if !$setting['explorer_mermoryonlymyorg']}-->checked<!--{/if}--> >
					<label class="form-check-label" for="explorer_mermoryonlymyorg2">本机构部门</label>
				</div>
				<span class="form-text">仅可以选择用户所在部门成员或可管理的部门成员</span>
			</div>
		</div>
		<div class="row mb-3">
			<label class="col-sm-2" for="catcreatememory">{lang allow_create_cat}</label>
			<div class="col-sm-10">
				<div class="form-check form-switch">
					<input type="checkbox" class="form-check-input" name="setting[explorer_catcreate]" id="catcreatememory" <!--{if (isset($setting['explorer_catcreate']) && $setting['explorer_catcreate']) || !isset($setting['explorer_catcreate'])}-->checked <!--{/if}--> />
				  </div>
			</div>
		</div>
		<div class="row mb-3">
			<label class="col-sm-2" for="textnumber">{lang finally_delete_setting}</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="setting[explorer_finallydelete]" onblur="checks()" id="textnumber" <!--{if isset($setting['explorer_finallydelete'])}-->value="{$setting[explorer_finallydelete]}"<!--{else}-->value="-1"<!--{/if}-->/>
				<ul class="form-text">
					<li>{lang explorer_finallydelete_text}</li>
					<li>{lang explorer_finallydelete_one}</li>
					<li>>={lang explorer_finallydelete_zreo}</li>
				</ul>
			</div>
		</div>
		<dl class="mb-3 d-grid">
            <input type="submit" value="{lang affirm}" class="btn btn-primary btn-round bodyloading"/>
          </dl>
	</form>
</div>

<script type="text/javascript" reload="1">
var recylenum = true;
//input框只能输入数字
function checks(){
	var value=jQuery('#textnumber').val();
	reg=/^-?\d+$/;
	if(reg.test(value)==true){
		$('.number').hide();
        recylenum = true;
	}else{
		$('.number').show();
        recylenum = false;
	}
	return false;
}

    //个人创建群组开关
    $('#usercreatememory').change(function () {
        if ($(this).prop('checked')) {
            $('#memorycreateinfo').removeClass('hide');
            //$('#usermemory_value').val(1);
        } else {
            $('#memorycreateinfo').addClass('hide');
            //$('#usermemory_value').val(0);
        }
    })

    //个人存储开关
    $('#usermemory').change(function () {
        if ($(this).prop('checked')) {
            $('#memoryinfo').removeClass('hide');
            //$('#usermemory_value').val(1);
        } else {
            $('#memoryinfo').addClass('hide');
            //$('#usermemory_value').val(0);
        }
    })

    //机构人员选择框切换
    $('.function-radio').find('input[name="setting[explorer_mermorygroupsetting]"]').change(function () {
        var val = $(this).val();
        if (val == 'appoint') {
            $('div.selectgroupuser').show();
        } else {
            $('div.selectgroupuser').hide();
        }
    })
    $('.function-radio').find('input[name="setting[explorer_mermoryusersetting]"]').change(function () {
        var val = $(this).val();
        if (val == 'appoint') {
            $('div.selectorguser').show();
        } else {
            $('div.selectorguser').hide();
        }
    })
    //版本数量设置框切换
    $('#fileversion').change(function () {
        if ($(this).prop('checked')) {
            $('#fileversionnum').removeClass('hide');
            //$(this).val(1);
        } else {
            $('#fileversionnum').addClass('hide');
            $('#fileVersionNumber').val(0);
            //$(this).val(0);
        }
    })
    function submitsetting(form) {
    	if(!recylenum) return false;
        $.post(form.action, jQuery(form).serialize(), function (data) {
            if (data['success']) {
				layer.alert(data['msg']+'{lang page_automatically_updated_after_three_seconds}');
                setTimeout(function () {
                    location.reload();
                }, 3000)
            } else {
				layer.alert(data['msg'], {skin:'lyear-skin-danger'});
            }
        }, 'json').fail(function (jqXHR, textStatus, errorThrown) {
            showmessage('操作失败，请稍后再试: ' + textStatus, 'error', 3000, 1);
        });
        return false;
    }
</script>